package com.feng.server.service.impl;

import com.feng.server.service.UserChatSession;
import io.netty.channel.Channel;

import java.util.HashMap;
import java.util.Map;

public class UserChatSessionImpl implements UserChatSession {
    private static Map<String, io.netty.channel.Channel> ChatSessionMap = new HashMap<>();
    @Override
    public  void registerSession(String userId, Channel channel) {
        System.out.print("userID:chanelID"+userId+":"+channel.id());
        ChatSessionMap.put(userId,channel);
    }

    @Override
    public void removeSession(String userId) {
        ChatSessionMap.remove(userId);
    }

    @Override
    public boolean existSession(String userId) {
        return false;
    }

    @Override
    public Channel getSessionChannel(String userId) {
        Channel channel = ChatSessionMap.get(userId);
        System.out.print("userID:chanelID"+userId+":"+channel.id());
        return channel;
    }
}
